
Ext.require([
    'Ext.form.*',
    'Ext.tip.QuickTipManager'
]);

Ext.onReady(function() {
    Ext.tip.QuickTipManager.init();
    var win;
    var formPanel = Ext.widget('form', {
        renderTo: 'login_extjs',
        frame: true,
        width: 320,
        x: 500,
        //y: 50,
        bodyPadding: 10,
        title: 'INICIO DE SESION',
        iconCls: 'icon-alpha',
        defaults: {
            anchor: '100%'
        },

        items: [{
            xtype: 'textfield',
            name: 'login',
            fieldLabel: '<b>Nombre Usuario</b>',
            style: 'margin-top:10px',
            allowBlank: false,
           
        }, {
            xtype: 'textfield',
            name: 'password',
            fieldLabel: '<b>Contraseña</b>',
            inputType: 'password',
            style: 'margin-top:10px',
            allowBlank: false,
           
        }],

        dockedItems: [{
            xtype: 'container',
            dock: 'bottom',
            layout: {
                type: 'hbox',
                align: 'middle'
            },
            padding: '0 5 1',

            items: [
			{
                xtype: 'button',
                text: 'INGRESAR',
                style: 'margin-left:200px',
                width: 100,
                handler: function() {
                    var form = this.up('form').getForm();
                    form.submit({
                        url: 'ingresar',	
						params: {
								submit: 'submit'
						},
						method: "post",
						success: function(form, action) {			
						
                        },
                        failure: function(form, action) {
									Ext.Msg.show({  
										title: '<b>ALPHA MANAGER</b>', //<- el título del diálogo  
										msg: '<b>ACCESO DENEGADO</b>', //<- El mensaje  
										icon: 'ext-mb-error',
									});	 
									                     
									//window.location = "login";
                        }		
						
                    });
                    if (form.isValid()) {
						Ext.MessageBox.show({
						   msg: 'Iniciando sesion ...',
						   width:300,
						   wait:true,
						   waitConfig: {interval:100},
						   
					   });
						setTimeout(function(){							
							window.location = "main";
						}, 1000);
						
						
                    }
                    
                    
                }
            }
            ]
        }]
    });
    



});

